package smashedapples.remoting
{
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.mxml.Operation;
	
	public class RemoteObject
	{
		public function RemoteObject(destination:String,endpoint:String)
		{
			this.destination = destination;
			this.endpoint = endpoint;
		}
		
		[Transient] public var destination : String;
		
		[Transient] public var endpoint : String;

		public function method( method:String, result:Function=null, fault:Function=null ):Operation
		{
			var operation : Operation = RemotingUtils.buildRemoteOp( this.destination, this.endpoint, method );
			
				operation.showBusyCursor = false;
				
				if( fault != null )
    				operation.addEventListener( FaultEvent.FAULT,fault );
    			
    			if( result != null )
    				operation.addEventListener( ResultEvent.RESULT,result );

			return operation;
		}
	}
}